package conf

import "os"

//basic
var (
	//服务监听地址
	serverbind = "0.0.0.0:9999"
	//日志级别 debug:0 info:1, warn:2, error:3, panic:4
	loglevel = "0"
)

//redis
var (
	netType  = "tcp"
	addr     = "127.0.0.1:6379"
	password = "root"
	dbIndex = "0"
	//redis连接池
	maxIdle = "2000"
	maxActive = "3000"
	idleTimeout = "300"
)

func init() {
	if os.Getenv("Server_Bind") != "" {
		serverbind = os.Getenv("Server_Bind")
	}
	if os.Getenv("Log_Level") != "" {
		loglevel = os.Getenv("Log_Level")
	}
	//redis
	if os.Getenv("Redis_Net_Type") != "" {
		netType = os.Getenv("Redis_Net_Type")
	}
	if os.Getenv("Redis_Host") != "" {
		addr = os.Getenv("Redis_Host")
	}
	if os.Getenv("Redis_Port") != "" {
		addr += ":" + os.Getenv("Redis_Port")
	}
	if os.Getenv("Redis_Password") != "" {
		password = os.Getenv("Redis_Password")
	}
	if os.Getenv("Redis_DbIndex") != "" {
		dbIndex = os.Getenv("Redis_DbIndex")
	}
	//redis pool
	if os.Getenv("Redis_MaxIdle") != "" {
		maxIdle = os.Getenv("Redis_MaxIdle")
	}
	if os.Getenv("Redis_MaxActive") != "" {
		maxIdle = os.Getenv("Redis_MaxActive")
	}
	if os.Getenv("Redis_IdleTimeout") != "" {
		maxIdle = os.Getenv("Redis_IdleTimeout")
	}
}

func GetServerBind() string {
	return serverbind
}
func GetLogLevel() string  {
	return loglevel
}

func GetRedisNetType() string {
	return netType
}
func GetRedisAddr() string {
	return addr
}

func GetRedisPassword() string {
	return password
}

func GetDbIndex() string {
	return dbIndex
}

func GetMaxIdle() string {
	return maxIdle
}

func GetMaxActive() string {
	return maxActive
}

func GetIdleTimeout() string {
	return idleTimeout
}